/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: HystrixClientFallbackFactory
 * @Package com.rx.service.base
 * @Description: 服务降级
 * @author: 陈锦韬
 * @date: 2020\4\20 0020
 * @version V1.0
 * @Copyright: 2020 陈锦韬  All rights reserved.
 */
package com.rx.school.service.feign;

import com.rx.core.enm.RESULT_CODE;
import com.rx.core.util.RxUtil;
import com.rx.uua.vo.UuaOrgInfo;
import com.rx.uua.vo.UuaUserInfo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author: Administrator
 * @Description: 服务降级
 * @date: 2020\4\20 0020
 */
@Slf4j
@Component
public class HystrixClientFallbackFactory implements FallbackFactory<FeignOrgInfoService> {
    @Override
    public FeignOrgInfoService create(Throwable cause) {
        log.info("user service exception:" + cause.getMessage());
        return new HystrixClientWithFallBackFactory(){
            @Override
            public UuaOrgInfo getDetail(UuaOrgInfo data) {
                RxUtil.CheckUtil.throwOut(RESULT_CODE.MESSAGE,"获取机构信息失败");
                return null;
            }
            @Override
            public UuaUserInfo getUserDetail(UuaUserInfo data) {
                RxUtil.CheckUtil.throwOut(RESULT_CODE.MESSAGE,"获取用户信息失败");
                return null;
            }
        };
    }
}
